<template>
	<view class="g-h5 body-content">
		<u-navbar back-text="返回" title="笔记"></u-navbar>
		<view class="note-content">
			<view class="note-book-name">书名：{{noteData.name}}</view>
			<textarea class="note-text" placeholder="请输入笔记大纲内容" v-model="noteData.content"></textarea>
			<view style="display: flex;align-items: center;">
				<view class="login-button" @tap.stop="complete">完成</view>
				<view class="com-text" @tap.stop="success">AI完善</view>
			</view>
			<view class="chat-text" v-if="successText">
				在柏拉图的《理想国》中，苏格拉底通过和格劳孔等人的对话，探讨了正义、美德、政治、教育等一系列重要的哲学问题，并提出了自己的见解。书中提出了理想国的概念，即一个由哲学家领导的国家，其中每个人都能够发挥自己的才能，为国家的利益而工作。通过这本书，我深刻认识到哲学的重要性，以及哲学家应该如何为政治和社会做出贡献。同时，我也认识到，正义和美德是构建一个理想国家的重要基石。这本书不仅是一部哲学著作，更是对人类社会的思考和探索，对我们今天的生活和社会建设仍有很大的启示意义。
			</view>
		</view>
		<u-tabbar v-model="tabCurrent" :list="tabList"></u-tabbar>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				noteData: {},
				tabList: [{
						iconPath: 'home',
						selectedIconPath: 'home-fill',
						text: '在读',
						customIcon: false,
						pagePath: '/pages/miniprogram/index'
			 					},
					{
						iconPath: 'photo',
						selectedIconPath: 'photo-fill',
						text: '书架',
						customIcon: false,
						pagePath: '/pages/miniprogram/books'
			 					},
					{
						iconPath: 'https://cdn.uviewui.com/uview/common/min_button.png',
						selectedIconPath: 'https://cdn.uviewui.com/uview/common/min_button_select.png',
						text: '书店',
						customIcon: false,
						pagePath: '/pages/miniprogram/bookshop'
			 					},
					{
						iconPath: 'play-right',
						selectedIconPath: 'play-right-fill',
						text: '我的',
						customIcon: false,
						pagePath: '/pages/miniprogram/user'
			 					},
			 				],
				tabCurrent: 0,
				successText: false,
				type: 1 // 2新增 1编辑
			}
		},
		onLoad(options) {
			this.noteData = JSON.parse(options.data)
			this.type = options.type || 1
		},
		methods: {
			complete() {
				if (this.type == 1) {
					this.$api.note_update(this.noteData.id, {
						...this.noteData,
						content: this.noteData.content,
						status: 2
					})
				}
				if (this.type == 2) {
					this.$api.note_create({
						image: 'https://wfqqreader-1252317822.image.myqcloud.com/cover/243/33889243/t6_33889243.jpg',
						content: this.noteData.content,
						tips: '',
						status: 1,
						label: [],
						name: '理想国（汉译世界学术名著丛书）',
						time: new Date().getTime()
					})
				}
				uni.showToast({ title: '保存成功' })
			},
			success() {
				this.successText = true
			}
		}
	}
</script>

<style scoped>
	.note-content {
		margin: 20rpx;
		background-color: #fff;
		border-radius: 12rpx;
		padding-bottom: 40rpx;
	}

	.note-book-name {
		padding: 20rpx;
		border-bottom: 1rpx solid #999;
	}

	.note-text {
		width: 630rpx;
		height: 400rpx;
		padding: 20rpx;
		background-color: #F0F0F0;
		margin: 20rpx;
		border-radius: 20rpx;
		font-size: 26rpx;
		line-height: 38rpx;
	}

	.login-button {
		margin-top: 40rpx;
		background-color: #FF7200;
		color: #fff;
		font-size: 36rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		border-radius: 8rpx;
		width: 480rpx;
		height: 80rpx;
		margin-left: 20rpx;
	}

	.com-text {
		margin-top: 40rpx;
		background-color: #FF7200;
		color: #fff;
		font-size: 36rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		border-radius: 8rpx;
		height: 80rpx;
		margin-left: 20rpx;
		padding: 0 20rpx;
	}

	.chat-text {
		width: 710rpx;
		min-height: 300rpx;
		background-color: red;
		border-radius: 20rpx;
		margin: 30rpx auto 0;
		color: #fff;
		padding: 20rpx;
	}
</style>